from django.shortcuts import render
from django.http import HttpResponse
from django.http.response import  JsonResponse
# Create your views here.
def goods(request):

    return HttpResponse('hello,goods')


def dates(request,year,mouth,day):
    # 可选变量路由
    return HttpResponse( str(year)+'-'+str(mouth)+'-'+str(day)) ;

def mygoods(request):

    if request.method=='GET' and request.GET.get('id') =='8888':
        return  JsonResponse({'zhuzi':888})
    else:
        return HttpResponse( request.method)


    #return HttpResponse("this is mygoods!")

def getUrldouyin(request):
    try:
        if  request.method == 'POST' and request.POST.get('token'):
            if request.POST.get('token') == '88888':
                result = {'urls': get_redis().decode('utf-8')}
                return JsonResponse(result)
            else:
                return JsonResponse({'urls':False})
        else:
            return JsonResponse({'urls':False})
    except Exception as e :
        return JsonResponse({'urls':False})
